package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * @EnumName FunctionLibraryExceptionEnum
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/27 12:05
 * @Version 1.0
 */
public enum FunctionLibraryExceptionEnum implements CustomExceptionCode {

    FUNCTION_SAVE_ERROR(300, "新增功能失败", 900),
    FUNCTION_UPDATE_ERROR(301, "修改功能失败", 900),
    FUNCTION_DELETE_ERROR(302, "删除功能失败", 900),
    FUNCTION_NAME_NOT_NULL(303, "功能名称不能为空", 900),
    FUNCTION_ID_NOT_NULL(304, "功能ID不能为空", 900),
    SITE_ID_NOT_NULL(305, "站点ID不能为空", 900),
    SITE_AS_FUNCTION_ERROR(306, "为站点分配功能失败", 900),
    FUNCTION_IS_PARENT(307, "该功能有子节点，请先删除子节点！", 900),
    FUNCTION_STATUS_NOT_NULL(308, "功能状态不能为空", 900),
    FUNCTION_TYPE_NOT_NULL(309, "功能类型不能为空", 900),

    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    FunctionLibraryExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static FunctionLibraryExceptionEnum getEnumByCode(Integer code){
        for(FunctionLibraryExceptionEnum functionLibraryExceptionEnum : FunctionLibraryExceptionEnum.values()){
            if(code.equals( functionLibraryExceptionEnum.getCode())){
                return functionLibraryExceptionEnum;
            }
        }
        return null;
    }
}
